(function() {

	var flag = getUrlParms("flag");

	var index = getUrlParms("index");

	//获取新闻对应的id
	var id = getUrlParms("id");

	'use strict';

	layui.use([ "jquery",'layer' ], function() {
		var $ = layui.$,
            layer = layui.layer;
		var html = "";
		$("#app .server .server-main-btn button").on("click", function() {
			$("#app .server-main-content>div").eq($(this).index() - 1).show().siblings().hide();
		});
		$("#app .server .server-main-btn button").first().click();
	 	if (flag == "download") {

	 		//获取下载的文件
            var index = layer.load(3)
            $.ajax({
                url : "/CivilAffairs/news/getDownloadFileList",
                type : "post",
                async : false,
                dataType : "json",
                success : function(result) {
                    layer.close(index);
                    if(checkResult(result)){
                        $(".text-area").html("<h2 style='text-align: center'>下载列表</h2></br>"+result.data);
                    }
                },
                error : function(result) {
                    layer.close(index);
                    reqError(result,"获取下载文件列表失败");
                }
            });
		}
	 	else if(flag == "bureau" && index == 1||flag == "bureau" && index == 2||flag == "bureau" && index == 3||flag ==null && index == null && id==null){
			for(var i=1;i<=30;i++){
				html+="<br>";
			}
			$(".text-area").html(html);
	 	}
		else{
	 	    //根据新闻的id从后台获取新闻内容
            $.ajax({
                url : "/CivilAffairs/news/getNewById",
                type : "post",
                async : false,
                data:{"newsId":id},
                dataType : "json",
                success : function(result) {
                	if(checkResult(result)){
                        $(".text-area").html(result.data);
					}
                },
                error : function() {
                    alert("系统异常,请稍后重试");
                }
            });
		}
	});
}());